<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <%@include file="../../../resources/inc/head.jsp" %>
    <link rel="stylesheet" href="<%=basePath%>resources/lib/layuiAdmin/style/login.css" media="all">
    <style>
        .layui-layout-admin .layui-header .layui-nav .layui-this:after, .layui-layout-admin .layui-header .layui-nav-bar {
            height: 2px;
            background-color: #5FB878;
        }

        @media screen and (max-width: 1080px) {
            .mobileTopLevelMenus[mobile] {
                display: inline-block;
            }

            .mobileTopLevelMenus .layui-nav-item {
                width: 140px;
                text-align: center;
                margin: 0px !important;
            }

            .site-mobile .site-tree-mobile, .topLevelMenus[pc] {
                display: none !important;
            }
        }

        @media screen and (min-width: 1080px) {
            .mobileTopLevelMenus[mobile] {
                display: none !important;
            }

            .site-mobile .site-tree-mobile, .topLevelMenus[pc] {
                display: inline-block;
            }
        }

        .layui-layout-admin .layui-header .layui-nav .layui-nav-child dd.layui-this, .layui-layout-admin .layui-header .layui-nav .layui-nav-child dd.layui-this a {
            background-color: #5FB878;
            color: #fff;
        }

    </style>
</head>
<body>
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">

        <div class="layadmin-user-login-box layadmin-user-login-header">
            <h2>修改安全密码</h2>
        </div>

        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password"
                       for="LAY-user-login-password"></label>
                <input type="password" name="securityPass" id="LAY-user-login-oldpass" lay-verify="pass|required"
                       placeholder="安全密码" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-cellphone"
                       for="LAY-user-login-cellphone"></label>
                <input type="text" name="mobile" id="LAY-user-login-newphone" lay-verify=required" placeholder="手机号"
                       class="layui-input">
            </div>
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-xs7">
                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode"
                               for="LAY-user-login-vercode"></label>
                        <input type="text" name="vercode" id="LAY-user-login-vercode" lay-verify="required"
                               placeholder="验证码" class="layui-input">
                    </div>

                    <div class="layui-col-xs5">
                        <div style="margin-left: 10px;">
                            <button type="button" class="layui-btn layui-btn-primary layui-btn-fluid"
                                    id="LAY-user-getsmscode">获取验证码
                            </button>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-reg-submit">修改</button>
            </div>
        </div>
    </div>

    <div class="layui-trans layadmin-user-login-footer">

    </div>

</div>


<script src="<%=basePath%>resources/lib/layuiAdmin/layui/layui.js"></script>
<link rel="stylesheet" href="<%=basePath%>resources/lib/pace/themes/green/pace-theme-material.css"/>
<script src="<%=basePath%>resources/js/jquery.1.12.4.min.js"></script>
<script src="<%=basePath%>resources/lib/pace/pace.min.js"></script>
<script>
    layui.config({
        base: '<%=basePath%>resources/lib/layuiAdmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', "form"], function () {
        var $ = layui.$
            , form = layui.form
            , router = layui.router()
            , setter = layui.setter
            , admin = layui.admin;

        form.render();
        document.onkeyup = function (e) {
            var code = e.charCode || e.keyCode;
            if (code == 13) {
                $("#submit").click();
            }
        }


        form.on('submit(LAY-user-reg-submit)', function (obj) {
            var field = obj.field;

            //确认密码
            var b = /^\d{6}$/;
            if (!b.test(field.securityPass)) {
                layer.msg("安全密码为六位数字");
                return;
            }
            if (!/^1[0-9]{10}/.test(field.mobile)) {
                layer.msg("新手机号格式不正确");
                return;
            }
            //请求接口
            layer.msg('修改中...', {icon: 16, shade: 0.01});
            $.ajax({
                url: "<%=basePath%>merchantUser/alterSecurityPassword.html",
                type: "post",
                data: {securityPass: field.securityPass},
                dataType: "JSON",
                success: function (data) {
                    if (data.success) {
                        layer.msg('修改安全密码成功', {
                            offset: '15px'
                            , icon: 1
                            , time: 1500
                        }, function () {
                            //重新加载父页面
                            parent.location.reload();
                        });
                    } else {
                        layer.msg(data.message);
                    }
                }
            });
        });


    });
</script>
</body>
</html>
